<?php
/**
 * Vip卡接口
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/6
 * Time: 19:08
 */

namespace App\Http\Controllers\MiniProgram;


use App\Http\Logics\MiniProgram\VipCardLogic;
use App\Http\Traits\VipCardTrait;
use App\Http\Controllers\BaseController;
class VipCardController extends BaseController
{
    use VipCardTrait;

    /**
     * @SWG\Get(
     *     path="/vipCard/list",
     *     tags={"VipCard"},
     *     description="获取会员卡列表",
     *     operationId="getVipCardList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="key",
     *         in="query",
     *         description="合作者key",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getVipCardList()
    {
        $key = $this->key;
        $data = [
            'key' => $key
        ];
        $response = VipCardLogic::getVipCardList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/vipCard/detail",
     *     tags={"VipCard"},
     *     description="获取会员卡详情",
     *     operationId="getVipCardDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="vip_card_id",
     *         in="query",
     *         description="会员卡ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getVipCardDetail()
    {
        $vip_card_id = $this->vip_card_id;
        $data = [
            'vip_card_id' => $vip_card_id
        ];
        $response = VipCardLogic::getVipCardDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/vipCard/getUser",
     *     tags={"VipCard"},
     *     description="获取用户VIP卡",
     *     operationId="getUserVipCard",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getUserVipCard()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = VipCardLogic::getUserVipCard($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}